package com.hello.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hello.common.log.annotation.Log;
import com.hello.common.log.enums.BusinessType;
import com.hello.common.security.annotation.RequiresPermissions;
import com.hello.system.domain.RentalDeviceProducts;
import com.hello.system.service.IRentalDeviceProductsService;
import com.hello.common.core.web.controller.BaseController;
import com.hello.common.core.web.domain.AjaxResult;
import com.hello.common.core.utils.poi.ExcelUtil;
import com.hello.common.core.web.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 设备产品（商城）Controller
 * 
 * @author hello
 * @date 2025-08-06
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/rentalDeviceProducts")
public class RentalDeviceProductsController extends BaseController
{
    private final IRentalDeviceProductsService rentalDeviceProductsService;

    /**
     * 查询设备产品（商城）列表
     */
    @RequiresPermissions("system:rentalDeviceProducts:list")
    @GetMapping("/list")
    public TableDataInfo list(RentalDeviceProducts rentalDeviceProducts)
    {
        startPage();
        List<RentalDeviceProducts> list = rentalDeviceProductsService.selectRentalDeviceProductsList(rentalDeviceProducts);
        return getDataTable(list);
    }

    /**
     * 导出设备产品（商城）列表
     */
    @RequiresPermissions("system:rentalDeviceProducts:export")
    @Log(title = "设备产品（商城）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RentalDeviceProducts rentalDeviceProducts)
    {
        List<RentalDeviceProducts> list = rentalDeviceProductsService.selectRentalDeviceProductsList(rentalDeviceProducts);
        ExcelUtil<RentalDeviceProducts> util = new ExcelUtil<RentalDeviceProducts>(RentalDeviceProducts.class);
        util.exportExcel(response, list, "设备产品（商城）数据");
    }

    /**
     * 获取设备产品（商城）详细信息
     */
    @RequiresPermissions("system:rentalDeviceProducts:query")
    @GetMapping(value = "/{productId}")
    public AjaxResult getInfo(@PathVariable("productId") Long productId)
    {
        return success(rentalDeviceProductsService.selectRentalDeviceProductsByProductId(productId));
    }

    /**
     * 新增设备产品（商城）
     */
    @RequiresPermissions("system:rentalDeviceProducts:add")
    @Log(title = "设备产品（商城）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RentalDeviceProducts rentalDeviceProducts)
    {
        return toAjax(rentalDeviceProductsService.insertRentalDeviceProducts(rentalDeviceProducts));
    }

    /**
     * 修改设备产品（商城）
     */
    @RequiresPermissions("system:rentalDeviceProducts:edit")
    @Log(title = "设备产品（商城）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RentalDeviceProducts rentalDeviceProducts)
    {
        return toAjax(rentalDeviceProductsService.updateRentalDeviceProducts(rentalDeviceProducts));
    }

    /**
     * 删除设备产品（商城）
     */
    @RequiresPermissions("system:rentalDeviceProducts:remove")
    @Log(title = "设备产品（商城）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{productIds}")
    public AjaxResult remove(@PathVariable Long[] productIds)
    {
        return toAjax(rentalDeviceProductsService.deleteRentalDeviceProductsByProductIds(productIds));
    }
}
